<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>新增供应商账号</title>
<jsp:include page="../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
	<form id="formSet1">
		<div class="fieldset1 tabel_col clearFix">
			<div class="fieldBox col_50">
                <div class="label">收款方</div>
                <div class="field">
                	<input type="text" id="rcptUnt" name="rcptUnt" class="ui-textbox" validate ="{required:true}"/>
                	<span class="requiredSymbol">*</span>
                </div>
            </div>
			<div class="fieldBox col_50">
                <div class="label">收款账号</div>
                <div class="field">
                	<input type="text" id="accNo" name="accNo" class="ui-textbox" validate ="{required:true,number:true}"/>
                	<span class="requiredSymbol">*</span>
                </div>
            </div>
			<div class="fieldBox col_50">
                <div class="label">开户行</div>
                <div class="field">
                	<input type="text" id="bkNm" name="bkNm" class="ui-textbox" validate ="{required:true}"/>
                	<span class="requiredSymbol">*</span>
                </div>
            </div>
			<div class="fieldBox col_50">
                 <div class="label">开户行行号</div>
                 <div class="field">
                 	<input type="text" id="bkNo" name="bkNo" class="ui-textbox" validate ="{required:true,number:true}"/>
                 	<span class="requiredSymbol">*</span>
                 </div>
			</div>
			<div class="fieldBox col_66_auto">
                 <div class="label">区域</div>
                 <div class="field">
                 	<jsp:include page="../system/sysRegion/region.jsp" flush="true" >
						<jsp:param name="regionShowLvl" value="2"/>
					</jsp:include>
                 </div>
			</div>
			<div class="fieldBox col_100">
				<div class="label">备注</div>
					<div class="field">
						<input type="text" id="bkRem" name="bkRem" class="ui-textbox" />
					</div>
			</div>
			<input id="orgId" name="orgId" style="display:none">
			<input id="orgCd" name="orgCd" style="display:none">
		</div>
</form>
</div>


<script type="text/javascript">
	var id = '${id}';
	var orgId = '${orgId}';
	var orgCd = '${orgCd}';
	$(function(){
		initData();
		var formSet1 = $('#formSet1').ligerForm({
			validate : true
		});
	});
	//定义父级调用事件
	frameElement.dialog.onOk = function () {
	     save();
	}
	           
	frameElement.dialog.onCancel = function () {
	     frameElement.dialog.close();
	}
	
	function save(){
		var form = liger.get("formSet1");
	    if (!form.valid()) {
	    	$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO , SQ_type: "warning" });
	        return false; //验证不通过，不执行以下代码
	    }
	    
	    var data = form.getData();
	    data["rgnPrCd"] = getRgnProvCd();//获取省代码
	    data["rgnCyCd"] = getRgnCityCd();//获取市代码
	    
	    var url = '<%=path%>/orgbankacc/sysOrgBankAcc/add.do';
	    if(id != ""){
	    	url = '<%=path%>/orgbankacc/sysOrgBankAcc/modify.do';
	    	data["id"]= id;
	    }
	    var wait_dialog;
	    $.ajax({
			type: 'post',
			dataType:'json',
			data:data,
			url: url,
			beforeSend: function(){
		          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
		     },
			success:function(msg){
				 wait_dialog.close();
				 if(msg.success == 1){
					 $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
					 parent.grid.reload();
					 parent.$.ligerDialog.close();
					 parent.$(".l-dialog,.l-window-mask").css("display","none"); 
					 parent.$("#addBtn").hide();
				 }else{
					 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				 }
			}
		});
	}
	function initData(){
    	if(!id){
    		$("#orgId").val(orgId);
        	$("#orgCd").val(orgCd);
    		return;
    	}
    	var _url = '<%=path%>/orgbankacc/sysOrgBankAcc/getById.do';
    	$.ajax({
    		type: 'get',
    		dataType:'json',
    		data:{id:id},
    		url: _url,
    		success:function(msg){
    			 if(msg.success == 1){
    				 setData(msg.data);//设置数据
    			 }else{
    				 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
    			 }
    		}
    	});
   	}
		
	//设置页面数据
    function setData(data){
    	setRgnProvCdUpdataValue(data.rgnPrCd);
    	setRgnCityCdUpdataValue(data.rgnCyCd);
    	setRegionSelectDataChange();
    	$("#rcptUnt").val(data.rcptUnt);
    	$("#accNo").val(data.accNo);
    	$("#bkNm").val(data.bkNm);
    	$("#bkNo").val(data.bkNo);
    	$("#bkRem").val(data.bkRem);
    	$("#orgId").val(data.orgId);
    	$("#orgCd").val(data.orgCd);
	};
</script>
</body>
</html>
